package com.sz.stock.service;

import com.sz.stock.mapper.StockMapper;
import com.sz.stock.model.Stock;
import com.sz.stock.model.StockExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StockServiceImpl implements IStockService {

    @Autowired
    private StockMapper stockMapper;

    @Override
    public List<Stock> getAll() {
        return stockMapper.selectByExample(null);
    }

    @Override
    public List<Stock> getOne(String code) {
        StockExample example = new StockExample();
        StockExample.Criteria criteria = example.createCriteria();
        criteria.andStockCodeEqualTo(code);
        return stockMapper.selectByExample(example);
    }

    @Override
    public Integer add(Stock stock) {
        return stockMapper.insertSelective(stock);
    }
}
